#include <iostream>
#include <string>
using namespace std;

class Solution 
{
public:
    int maxOperations(string s)
    {
        int ans = 0, cnt = 0;
        for (int i = 0; i < s.size(); i++)
        {
            if (s[i] == '1')
                cnt++;
            else if (i && s[i - 1] == '1')
                ans += cnt;
        }

        return ans;
    }
};

int main()
{
    Solution s;
    string str = "0100111001";
    s.maxOperations(str);
    return 0;
}